package com.amc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.amc.dao.IUserDao;
import com.amc.entity.Address;
import com.amc.entity.Customer;
import com.amc.service.IUserService;


@Service(value="userService")
public class UserServiceImpl implements IUserService {

	private IUserDao dao;
	
	@Resource
	public void setDao(IUserDao dao) {
		this.dao = dao;
	}
	
	@Override
	@Transactional
	public Customer login(String username, String password) {
		return dao.queryUser(username, password);
	}
	
	@Override
	@Transactional
	public boolean register(String username, String password) {
		
		return dao.insertUser(username, password);
	}
	
	@Override
	@Transactional
	public boolean insertAddress(Address address,String customerId) {
		return dao.insertAddress(address, customerId);
	}
	
	@Override
	@Transactional
	public boolean updateAddress(Address address,String customerId) {
		return dao.updateAddress(address,customerId);
	}
	
	@Override
	@Transactional
	public boolean deleteAddress(String addressId,String customerId) {
		return dao.deleteAddress(addressId,customerId);
	}
	
	@Override
	@Transactional
	public List<Address> queryAllAddress(String customerId) {
		return dao.queryAllAddress(customerId);
	}

	@Override
	@Transactional
	public Customer queryCustomer(String customerId) {
		return dao.queryCustomer(customerId);
	}

}
